import * as api from '@/api/employees';

const state = {
  // 员工列表
  list: {
    rows: [],
    total: 0,
  },
  // 部门列表
  departmentList: [],
};

const mutations = {
  SET_LIST (state, newValue) {
    state.list = newValue;
  },
  SET_DEPARTMENT_LIST (state, newValue) {
    state.departmentList = newValue;
  },
};

const actions = {
  async updateList ({ commit }, params) {
    const res = await api.getList(params);
    commit('SET_LIST', res);
  },
  async updateDepartmentList ({ commit }) {
    const res = await api.getDepartmentList();
    commit('SET_DEPARTMENT_LIST', res);
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}